package com.pakazaka.layer.tiles;

import com.pakazaka.enums.TilePropertyType;
import java.awt.Dimension;

/**
 * @author Remi
 */
public class Tile {

    public static final int WIDTH = 12, HEIGHT = 16;
    public static final Dimension SIZE = new Dimension(WIDTH, HEIGHT);
    private final int maxDurability, currentDurability;
    private int id, accelerationFactor;
    private final TilePropertyType[] properties;
    private boolean opened;

    public Tile(int id, int durability, TilePropertyType[] properties) {
        this.id = id;
        this.currentDurability = durability;
        this.maxDurability = durability;
        this.properties = properties;
    }

    public Tile(int id, int durability, TilePropertyType[] properties, boolean opened) {
        this.id = id;
        this.currentDurability = durability;
        this.maxDurability = durability;
        this.properties = properties;
        this.opened = opened;
    }

    @Override
    public Tile clone() throws CloneNotSupportedException {
        return new Tile(id, maxDurability, properties, opened);
    }

    //вызывается, когда герой наступает на тайл
    public void walkThrough() {
        System.out.println("default walked");
    }

    public int getId() {
        return id;
    }

    public void setId(int tileId) {
        id = tileId;
    }

    public boolean isPropertyExist(TilePropertyType property) {
        for (TilePropertyType p : properties) {
            if (p.equals(property)) {
                return true;
            }
        }
        return false;
    }

    public boolean canWalk() {
        return isPropertyExist(TilePropertyType.CAN_WALK);
    }
}
